
var parentJson = {};
parentJson.bakUrl="http://localhost:8081/unite_platform/meeting_info/toSelect";
parentJson.jsType="add";
parentJson.parameter="";
parentJson.showType="";
var now = getDay(0); 
var username = sessionStorage.getItem("name");
var userid = sessionStorage.getItem("userId");
var dingdingUserData;
var result;
var thenum = 0;

	$.ajax({
			url: '../../meeting_info/fillAdd'
			,type:'post'
			,dataType:'json'
			,contentType: "application/json; charset=utf-8"
			,data:JSON.stringify(parentJson)  
			,success: function(res){
				//请求成功后			
				  if(res.status==1000){
					layer.msg(res.msg);
				  }else{
					  //先填充complexselect的下拉框
			
					layui.each(res.data.select,function(inx,val){
						layui.each(val,function(inxSub,valSub){
							  $("select[name='"+inx+"']").append('<option value="'+valSub.value1+'">'+valSub.key1+'</option>');
						  })
					  });
					//form.render('select');
					//form.val('form1',res.data.field);		
				//	document.getElementById("mno").value=res.data.field.mno;
				  }	
			}
	});

       $.ajax({
   		url: "../../adminmanager/user/getUserTreeSelect"
   		,type:'post'
   		,async: false
   		,contentType: "application/json; charset=utf-8"
   		,dataType:'json'
   		,success: function(res){
			//alert(res);
   			dingdingUserData = res.data;
   		}
       ,error: function(XMLHttpRequest, textStatus, errorThrown) {
                        alert(XMLHttpRequest.status);
                        alert(XMLHttpRequest.readyState);
                        alert(textStatus);
                    }
   	});
   var calendar = new lCalendar();
   calendar.init({
	'trigger': '#searchDate',
	'type': 'date',
	'maxDate': '2099-12-31',
	'minDate': now
});
function ICalendarClick(){
	
}
$(document).ready(function(){
/*	alert(sessionStorage.getItem("reload"));*/
    if(sessionStorage.getItem("reload")=='true'){
	     window.location.reload();
		sessionStorage.setItem("reload", false);
		console.log("reload"); 
	}else{

	var jsona =sessionStorage.getItem("plansession");
 	var jsonparse = JSON.parse(jsona);
    if(jsonparse==null||jsonparse.length==0){
		sessionStorage.setItem("plansession", JSON.stringify([]));
	  	addform();	
        addoperation();
	}else{
		sessionStorage.setItem("plansession", JSON.stringify([]));
		addplan(jsonparse);
		addoperation();
	}
	document.getElementById("commituserid0").value=sessionStorage.getItem("valuearr");		
	document.getElementById("commituser0").value=sessionStorage.getItem("namearr");	
	sessionStorage.setItem("valuearr", []);
	sessionStorage.setItem("namearr", []);
	$('#name').text(sessionStorage.getItem("name"));
	$('#searchDate').val(now);
	$('#addButton').on('click',addform);
	$('#saveButton').on('click',saveInfo);
	$(document).on('click','input[jsonKey="commituser"]',function(){
		var valueInput = $(this).attr('jsonKey')+'id'+$(this).attr('index');
		var nameInput = $(this).attr('jsonKey')+$(this).attr('index');
		
		var sendData1 = [];
		//var insertArray1 = [];
		$('div[itemDiv]').each(function(i,obj){
			var insertJson1 = {};
			$(obj).find('textarea[jsonKey]').each(function(j,el){
					var key = $(el).attr('jsonKey');
					insertJson1[key] = $(el).val();
					key = null;
			});
			$(obj).find('select[jsonKey]').each(function(j,el){
					var key = $(el).attr('jsonKey');
					insertJson1[key] = $(el).val();
					key = null;
			});
			$(obj).find('input[jsonKey]').each(function(j,el){
					var key = $(el).attr('jsonKey');
					insertJson1[key] = $(el).val();
					//console.log(insertJson);
					key = null;
			});
			sendData1.push(insertJson1);
		});
		sessionStorage.setItem("plansession", JSON.stringify(sendData1));
		sessionStorage.setItem("valuearr", document.getElementById('commituserid0').value);
		sessionStorage.setItem("namearr", document.getElementById('commituser0').value);
		sessionStorage.setItem("theheight",document.body.clientHeight);
		window.location.href='../adminmanager/tomobileUsersTree?valueInput='+valueInput+'&nameInput='+nameInput ;
  /*		var index = layer.open({
			type: 2,
			maxmin: true,
			title: '选择人员',
			area: ["300px", "600px"],
			content: '../adminmanager/toUsersTree?valueInput='+valueInput+'&nameInput='+nameInput,
			btn: ['确定', '取消'] ,
			yes: function(index, layero){
			    //do something
			    layer.close(index); //如果设定了yes回调，需进行手工关闭
			},
			btn2: function(index, layero){
			    //do something
			    layer.close(index); //如果设定了yes回调，需进行手工关闭
			},
			success: function(layero, index){
			}
		});
		layer.full(index);*/
//		setUserXmselectOne([],$(this).attr('index'),$(this).attr('jsonKey'))
	});
	$(document).on('click','div[deleteIndex]',function(){
		var obj = this;
		dd.ready(function(){
			dd.device.notification.confirm({
				message: "确认删除此工作计划吗？",
				title: "提示",
				buttonLabels: ['是', '否'],
				onSuccess : function(result) {
					//onSuccess将在点击button之后回调
					/*
		        {
		            buttonIndex: 0 //被点击按钮的索引值，Number类型，从0开始
		        }
					 */
					if(result.buttonIndex == 0){
						$('div[itemDiv="'+$(obj).attr('deleteIndex')+'"]').remove();
					}
				},
				onFail : function(err) {}
			});
		})
	});
	
	}
	
	
});
function saveInfo(){
	sessionStorage.setItem("valuearr", []);
	sessionStorage.setItem("namearr", []);
	showloading();
	try {
		var imgStr = "";
		var sendData = {};
		var insertArray = [];
		var checkFlag = true;
		$('div[itemDiv]').each(function(i,obj){
			var insertJson = {};
			$(obj).find('textarea[jsonKey]').each(function(j,el){
				if($(el).parent().parent().parent().parent().find('span').text() == '*' && $(el).val() == ''){
					alert($(el).parent().parent().parent().parent().find('h5').text()+"为必填项");
					checkFlag = false;
					return false;
				}else{
					var key = $(el).attr('jsonKey');
					insertJson[key] = $(el).val();
					key = null;
				}
			});
			$(obj).find('select[jsonKey]').each(function(j,el){
				if($(el).parent().parent().parent().parent().find('span').text() == '*' && $(el).val() == ''){
					alert($(el).parent().parent().parent().parent().find('h5').text()+"为必填项");
					checkFlag = false;
					return false;
				}else{
					var key = $(el).attr('jsonKey');
					insertJson[key] = $(el).val();
					key = null;
				}
			});
			if(checkFlag){
				$(obj).find('input[jsonKey]').each(function(j,el){
					if($(el).parent().find('span').text() == '*' && $(el).val() == ''){
						alert($(el).parent().find('h5').text()+"为必填项");
						checkFlag = false;
						return false;
					}else{
						var key = $(el).attr('jsonKey');
						insertJson[key] = $(el).val();
						//console.log(insertJson);
						key = null;
					}
				});
			}else{
				return false;
			}
			insertJson.plantype=1;
			insertJson.flag=10;
			insertJson.planuserid=userid;
			insertJson.planuser=username;
			insertJson.plantime=insertJson.startplantime+'-'+insertJson.endplantime;
			/*insertJson.commituserid=$("#commituserid0").val()//commituserid0.value;
			insertJson.commituser=commituser0.value;*/
			insertJson.checkuserid=$("#commituserid0").val()//commituserid0.value;
			insertJson.checkuser=commituser0.value;
			insertJson.plandate=$("#searchDate").val();
			insertJson.lrr = userid;
			insertJson.xgr = userid;
			insertArray.push(insertJson);
		});
		sendData.insertArray = insertArray;
		console.log(sendData);
		if(checkFlag){
			$.ajax({
				url: "../../work_plan_info/addNewArray"
				,type:'post'
				,dataType:'json'
				,async: false
				,contentType: "application/json; charset=utf-8"
				,data:JSON.stringify(sendData) 
				,success: function(res){
					console.log(res)
					if(res.status==1000){
						layer.msg(res.msg);
					}else{
						layer.msg(res.msg,{time:1000},function(){
							//history.go(-1);
							url = "../../mobile_page/index";//此处拼接内容
	                        window.location.href = url;
						});
					}
				}
			    });
		}
/*		console.log(insertArray.length);*/
	} catch (e) {
		console.log(e)
	} finally{
		hideloading();
	}	
	
	
	
}	

function addform(){
	var itemDivIndex = $('div[itemDiv]').length;
    $('#f_div').append('<div class="col_box" itemDiv="'+thenum+'">'
    					+'<div class="widget-header widget-header-flat widget-header-small add_pad_tb10p add_mar_tb7p">'
						+'<h5 id="wentishuomingTitle" class="black">工作计划'+(itemDivIndex+1)+'</h5>'
						+'<div deleteIndex="'+thenum+'" class="bt_delete bg_orange">删除</div><div class="clearfix"></div>'
					+'</div>'
					  +'<div class="widget-box add_mar_tb7p">'
					  +'<div class="widget-header widget-header-flat widget-header-small add_pad_tb10p add_bor_tbgrey">'				
					  +'<h5><i class="iconfont">&#xe600;</i>&nbsp;工作内容</h5><span class="red">*</span>'						  
					  +'</div>'				
					  +'<div class="widget-body zhediebox1">'					
					  +'<div class="widget-main pd_div" style="padding:0;">'					
					  +'<div class="clearfix jy_div" style="padding:0;">'						
					  +'<textarea id="content'+thenum+'"  jsonKey="content" name="content" rows="" cols="" class="pull-left add_pad_tb10p add_bor_none" placeholder="请填写工作内容"></textarea>'								
					  +'</div>'						
							+'</div>'						
							+'</div>'					
							+'</div>'				
							+'		<div class="widget-box add_mar_tb7p">'
							+'			<div class="widget-header widget-header-flat widget-header-small add_pad_tb10p add_bor_tbgrey">'
							+'				<h5><i class="iconfont">&#xe600;</i>&nbsp;等级</h5><span class="red"></span>'
							+'				<select id="level'+thenum+'" jsonKey="level" class="pull-right add_bor_none" style="width: 70%;margin-right: 2%;">'
							+'				 <option value ="A1">A1</option>'
	  						+'				<option value ="A2">A2</option>'
					     	+'				<option value ="A3">A3</option>'
							+'				<option value ="B1">B1</option>'
							+'				 <option value ="B2">B2</option>'
	  						+'				<option value ="B3">B3</option>'
					     	+'				<option value ="C1">C1</option>'
							+'				<option value ="C2">C2</option>'
							+'				<option value ="C3">C3</option>'
							+'				</select> ' 
							+'			</div>'
							+'		</div>'
							+'		<div class="widget-box add_mar_tb7p">'
							+'			<div class="widget-header widget-header-flat widget-header-small add_pad_tb10p add_bor_tbgrey">'
							+'				<h5><i class="iconfont">&#xe600;</i>&nbsp;预计时长</h5><span class="red"></span>'
							+'				<input type="text" id="expecttime'+thenum+'" placeholder="请输入预计时长" jsonKey="expecttime" autocomplete="off"   class="pull-right add_bor_none" style="width: 70%;margin-right: 2%"/>'
							+'			</div>'
							+'		</div>'
							+'<div>'			
		                    +'<div class="widget-box add_mar_tb7p">'
							+'<div class="widget-header widget-header-flat widget-header-small add_pad_tb10p add_bor_tbgrey">'
							+'<h5><i class="iconfont">&#xe609;</i>&nbsp;预计执行时间</h5><span class="red"></span>'
							+'<input type="text" id="endplantime'+thenum+'" readonly="readonly" placeholder="结束时间" jsonKey="endplantime" class="pull-right add_bor_none" autocomplete="off" style="width: 25%;margin-right: 2%;"></input>'
						    +'<div class="pull-right" style="font-weight:bold; margin-right:2%;">～</div>'
							+'<input type="text" id="startplantime'+thenum+'" readonly="readonly" placeholder="开始时间" jsonKey="startplantime" class="pull-right add_bor_none" autocomplete="off" style="width: 25%;margin-right: 2%;"></input>'
							+'</div>'
							+'</div>'
							+'<div>'			
		                    +'<div class="widget-box add_mar_tb7p" style="display:none">'
							+'<div class="widget-header widget-header-flat widget-header-small add_pad_tb10p add_bor_tbgrey">'
							+'<h5><i class="iconfont">&#xe609;</i>&nbsp;预计完成时间</h5><span class="red"></span>'
							+'<input type="text" id="enddate'+thenum+'" readonly="readonly" placeholder="请选择预计完成时间" jsonKey="enddate" class="pull-right add_bor_none" autocomplete="off" style="width: 60%;margin-right: 2%;"/>'
							+'</div>'
							+'</div>'
							+'</div>'
							+'		<div class="widget-box add_mar_tb7p">'
							+'			<div class="widget-header widget-header-flat widget-header-small add_pad_tb10p add_bor_tbgrey">'
							+'				<h5><i class="iconfont">&#xe609;</i>&nbsp;描述</h5><span class="red"></span>'
							+'				<input type="text" id="description'+thenum+'" placeholder="请输入相关描述" jsonKey="description" autocomplete="off"   class="pull-right add_bor_none" style="width: 70%;margin-right: 2%"/>'
							+'			</div>'
							+'		</div>'
					  +'<div class="widget-box add_mar_tb7p" style="display:none">'
					  +'<div class="widget-header widget-header-flat widget-header-small add_pad_tb10p add_bor_tbgrey" style="border:0;">'				
					  +'<h5><i class="iconfont">&#xe609;</i>&nbsp;心得体会</h5><span class="red"></span>'						  
					  +'</div>'				
					  +'<div class="widget-body zhediebox1">'					
					  +'<div class="widget-main pd_div" style="padding:0;">'					
					  +'<div class="clearfix jy_div" style="padding:0;">'						
					  +'<textarea id="conclusion'+thenum+'"  jsonKey="conclusion" name="conclusion" rows="" cols="" class="pull-left add_bor_none add_pad_tb10p" placeholder="请填写心得体会"></textarea>'								
					  +'</div>'						
							+'</div>'						
							+'</div>'					
							+'</div>'
							+'<div>'
							+'<input type="hidden" id="checkuserid'+thenum+'" jsonKey="checkuserid"/>'
							+'<input type="hidden" id="checkuser'+thenum+'" jsonKey="checkuser"/>'
							+'</div>');					
	var replydatecalendar = new lCalendar();

    replydatecalendar.init({
    	'trigger': '#enddate'+thenum,
    	'type': 'datetime',
    	'maxDate': '2099-12-31 23:59:59',
    	'minDate':  now
    });
	var startplancalendar = new lCalendar();
	    startplancalendar.init({
	    	'trigger': '#startplantime'+thenum,
	    	'type': 'plantime',
	    	'maxDate': '23:59',
	    	'minDate':  now
	 });
	var endplancalendar = new lCalendar();
	    endplancalendar.init({
	    	'trigger': '#endplantime'+thenum,
	    	'type': 'plantime',
	    	'maxDate': '23:59',
	    	'minDate':  now
	 });
/*var plandatecalendar = new lCalendar();

    plandatecalendar.init({
    	'trigger': '#plandate'+thenum,
    	'type': 'date',
    	'maxDate': '2099-12-31',
    	'minDate':  now
    });*/
//	setUserXmselect([],thenum);
    thenum++;
}

function addplan(jsonparse){
	for(var i = 0 ;i<jsonparse.length;i++){
	var itemDivIndex = $('div[itemDiv]').length;
    $('#f_div').append('<div class="col_box" itemDiv="'+thenum+'">'
    					+'<div class="widget-header widget-header-flat widget-header-small add_pad_tb10p add_mar_tb7p">'
						+'<h5 id="wentishuomingTitle" class="black">工作计划'+(itemDivIndex+1)+'</h5>'
						+'<div deleteIndex="'+thenum+'" class="bt_delete bg_orange">删除</div><div class="clearfix"></div>'
					+'</div>'
					  +'<div class="widget-box add_mar_tb7p">'
					  +'<div class="widget-header widget-header-flat widget-header-small add_pad_tb10p add_bor_tbgrey">'				
					  +'<h5><i class="iconfont">&#xe600;</i>&nbsp;工作内容</h5><span class="red">*</span>'						  
					  +'</div>'				
					  +'<div class="widget-body zhediebox1">'					
					  +'<div class="widget-main pd_div" style="padding:0;">'					
					  +'<div class="clearfix jy_div" style="padding:0;">'						
					  +'<textarea id="content'+thenum+'"  jsonKey="content" name="content" rows="" cols="" class="pull-left add_pad_tb10p add_bor_none" placeholder="请填写工作内容" ></textarea>'								
					  +'</div>'						
							+'</div>'						
							+'</div>'					
							+'</div>'				
							+'		<div class="widget-box add_mar_tb7p">'
							+'			<div class="widget-header widget-header-flat widget-header-small add_pad_tb10p add_bor_tbgrey">'
							+'				<h5><i class="iconfont">&#xe600;</i>&nbsp;等级</h5><span class="red"></span>'
							+'				<select id="level'+thenum+'" jsonKey="level" class="pull-right add_bor_none" style="width: 70%;margin-right: 2%;">'
							+'				 <option value ="A1">A1</option>'
	  						+'				<option value ="A2">A2</option>'
					     	+'				<option value ="A3">A3</option>'
							+'				<option value ="B1">B1</option>'
							+'				 <option value ="B2">B2</option>'
	  						+'				<option value ="B3">B3</option>'
					     	+'				<option value ="C1">C1</option>'
							+'				<option value ="C2">C2</option>'
							+'				<option value ="C3">C3</option>'
							+'				</select> ' 
							+'			</div>'
							+'		</div>'
							+'		<div class="widget-box add_mar_tb7p">'
							+'			<div class="widget-header widget-header-flat widget-header-small add_pad_tb10p add_bor_tbgrey">'
							+'				<h5><i class="iconfont">&#xe600;</i>&nbsp;预计时长</h5><span class="red"></span>'
							+'				<input type="text" id="expecttime'+thenum+'" placeholder="请输入预计时长" jsonKey="expecttime" autocomplete="off"   class="pull-right add_bor_none" value="'+jsonparse[i].expecttime+'" style="width: 70%;margin-right: 2%"/>'
							+'			</div>'
							+'		</div>'					
							+'<div>'				
		                    +'<div class="widget-box add_mar_tb7p">'
							+'<div class="widget-header widget-header-flat widget-header-small add_pad_tb10p add_bor_tbgrey">'
							+'<h5><i class="iconfont">&#xe609;</i>&nbsp;预计执行时间</h5><span class="red"></span>'
							+'<input type="text" id="endplantime'+thenum+'" readonly="readonly" placeholder="结束时间" jsonKey="endplantime" class="pull-right add_bor_none" autocomplete="off" value="'+jsonparse[i].endplantime+'" style="width: 25%;margin-right: 2%;"></input>'
						    +'<div class="pull-right" style="font-weight:bold; margin-right:2%;">～</div>'
							+'<input type="text" id="startplantime'+thenum+'" readonly="readonly" placeholder="开始时间" jsonKey="startplantime" class="pull-right add_bor_none" autocomplete="off"  value="'+jsonparse[i].startplantime+'" style="width: 25%;margin-right: 2%;"></input>'
							+'</div>'
							+'</div>'
							+'<div>'			
		                    +'<div class="widget-box add_mar_tb7p" style="display:none">'
							+'<div class="widget-header widget-header-flat widget-header-small add_pad_tb10p add_bor_tbgrey">'
							+'<h5><i class="iconfont">&#xe609;</i>&nbsp;预计完成时间</h5><span class="red"></span>'
							+'<input type="text" id="enddate'+thenum+'" readonly="readonly" placeholder="请选择预计完成时间" jsonKey="enddate" class="pull-right add_bor_none" autocomplete="off" style="width: 60%;margin-right: 2%;"/>'
							+'</div>'
							+'</div>'
							+'</div>'
							+'		<div class="widget-box add_mar_tb7p">'
							+'			<div class="widget-header widget-header-flat widget-header-small add_pad_tb10p add_bor_tbgrey">'
							+'				<h5><i class="iconfont">&#xe609;</i>&nbsp;描述</h5><span class="red"></span>'
							+'				<input type="text" id="description'+thenum+'" placeholder="请输入相关描述" jsonKey="description" autocomplete="off"   value="'+jsonparse[i].description+'"  class="pull-right add_bor_none" style="width: 70%;margin-right: 2%"/>'

							+'			</div>'
							+'		</div>'
							

					  +'<div class="widget-box add_mar_tb7p" style="display:none">'
					  +'<div class="widget-header widget-header-flat widget-header-small add_pad_tb10p add_bor_tbgrey" style="border:0;">'				
					  +'<h5><i class="iconfont">&#xe609;</i>&nbsp;心得体会</h5><span class="red"></span>'						  

					  +'</div>'				
					  +'<div class="widget-body zhediebox1">'					
					  +'<div class="widget-main pd_div" style="padding:0;">'					
					  +'<div class="clearfix jy_div" style="padding:0;">'						
					  +'<textarea id="conclusion'+thenum+'"  jsonKey="conclusion" name="conclusion" rows="" cols="" class="pull-left add_bor_none add_pad_tb10p" placeholder="请填写心得体会"></textarea>'								
					  +'</div>'						
							+'</div>'						
							+'</div>'					
							+'</div>'
		/*					+'<div>'			
		                    +'<div class="widget-box">'
							+'<div class="widget-header widget-header-flat widget-header-small">'
							+'<h5>计划日期</h5><span class="red">*</span>'
							+'<input type="text" id="plandate'+thenum+'" placeholder="请选择计划日期" jsonKey="plandate" class="pull-right" autocomplete="off" style="width: 78%;margin-right: 2%;"/>'
							+'</div>'
							+'</div>'
							+'</div>'*/
							+'<div>'
//							+'<div class="widget-box">'
//							+'<div class="widget-header widget-header-flat widget-header-small">'
//							+'<h5>检视人</h5><span class="red">*</span>'
							+'<input type="hidden" id="checkuserid'+thenum+'" jsonKey="checkuserid"/>'
							+'<input type="hidden" id="checkuser'+thenum+'" jsonKey="checkuser"/>'
//							+'<div id="checkuseridTree'+thenum+'" class="pull-right" style="width: 78%;margin-right: 2%;border:none;"></div>'
//							+'</div></div></div>'
							+'</div>');
							

	document.getElementById("content"+thenum).value=jsonparse[i].content;		
	document.getElementById("level"+thenum).value=jsonparse[i].level;		
	var replydatecalendar = new lCalendar();

    replydatecalendar.init({
    	'trigger': '#enddate'+thenum,
    	'type': 'datetime',
    	'maxDate': '2099-12-31 23:59:59',
    	'minDate':  now
    });
	var startplancalendar = new lCalendar();
	    startplancalendar.init({
	    	'trigger': '#startplantime'+thenum,
	    	'type': 'plantime',
	    	'maxDate': '23:59',
	    	'minDate':  now
	 });
	var endplancalendar = new lCalendar();
	    endplancalendar.init({
	    	'trigger': '#endplantime'+thenum,
	    	'type': 'plantime',
	    	'maxDate': '23:59',
	    	'minDate':  now
	 });

    thenum++;
	}
}


//设置xmselect
function setUserXmselectOne(dataArray,colIndex,col){
	var layerndex = layer.open({
		type: 1,
		maxmin: true,
		title: '选择人员',
		area: ['300px', '600px'],
		content: '<div id="demo1" class="xm-select-demo-alert"></div>',
		success: function(layero, index){
			//这里因为内容过少, 会被遮挡, 所以简单修改了下样式
			document.getElementById('layui-layer' + index).getElementsByClassName('layui-layer-content')[0].style.overflow = 'unset';
			//渲染多选
			var demoSelect = xmSelect.render({
				el: '#demo1',
				autoRow: true,
				filterable: true,
				theme: {
					color: '#669fc7',
				},
				style: {
					marginTop: '2px',
					borderRadius: '6px',
				},
				tree: {
					show: true,
					simple: false,
					showFolderIcon: true,
					showLine: true,
					indent: 20,
					expandedKeys: [ -3 ],
				},
				model: {
					label: {
						type: 'block',
						block: {
							//最大显示数量, 0:不限制
							showCount: 1,
							//是否显示删除图标
							showIcon: true,
						}
					}
				},
				on: function(data){
					//arr:  当前多选已选中的数据
					//setxmSelectValueToInput(data.arr,colIndex,col)
					
				},
				toolbar: {
					show: true,
					list: ['ALL', 'REVERSE', 'CLEAR']
				},
				filterable: true,
				direction: 'down',
				height: 300,
				data:dingdingUserData
			});
			//有数据
			if(dataArray[colIndex] != undefined){
				demoSelect.setValue(dataArray[colIndex][col+'id'].split(','));	
			}
			setTimeout(function(){
				demoSelect.opened();
			}, 800);
		}
	});
	layer.full(layerndex);
	
}
function setUserXmselect(dataArray,index){
	//提交人
	var commituserxmSelect = xmSelect.render({
		el: '#commituserTree',
		autoRow: true,
		name: 'commituserTree',
		style: {
			marginTop: '2px',
			borderRadius: '6px',
		},
//		radio:true,
//		clickClose: true,
		theme: {
			color: '#669fc7',
		},
		direction: 'up',
		toolbar:{
			show: true,
			list: [ 'ALL', 'CLEAR', 'REVERSE' ]
		},
		filterable: true,
		searchTips:"输入名字进行搜索",
		model: {
			label: {
				type: 'block',
				block: {
					//最大显示数量, 0:不限制
					showCount: 1,
					//是否显示删除图标
					showIcon: true,
				}
			}
		},
		on: function(data){
			//arr:  当前多选已选中的数据
            	var valueArray = [];
				var nameArray = [];
				for (var i = 0; i < dataArray.length; i++) {
					valueArray.push(dataArray[i].value);
					nameArray.push(dataArray[i].name);
				}
				parent.$('#'+col+'id').val(valueArray.join(','));
				parent.$('#'+col).val(nameArray.join(','));
			//setxmSelectValueToInput(data.arr,index,'commituser')
		},
		tree: {
			show: true,
			showFolderIcon: true,
			showLine: true,
			indent: 20,
			expandedKeys: [ -1 ],
		},
		height: 100,
		data:dingdingUserData
	});
	//检视人
	var checkuseridSelect = xmSelect.render({
		el: '#checkuseridTree'+index,
		autoRow: true,
		name: 'checkuseridTree',
		style: {
			marginTop: '2px',
			borderRadius: '6px',
		},
//		radio:true,
//		clickClose: true,
		theme: {
			color: '#669fc7',
		},
		direction: 'up',
		toolbar:{
			show: true,
			list: [ 'ALL', 'CLEAR', 'REVERSE' ]
		},
		filterable: true,
		searchTips:"输入名字进行搜索",
		model: {
			label: {
				type: 'block',
				block: {
					//最大显示数量, 0:不限制
					showCount: 1,
					//是否显示删除图标
					showIcon: true,
				}
			}
		},
		on: function(data){
	
			//arr:  当前多选已选中的数据
			setxmSelectValueToInput(data.arr,index,'checkuser')
		},
		tree: {
			show: true,
			showFolderIcon: true,
			showLine: true,
			indent: 20,
			expandedKeys: [ -1 ],
		},
		height: 100,
		data:dingdingUserData
	});
	//有数据
	if(dataArray[index] != undefined){
		commituserxmSelect.setValue(dataArray[index].dutyuserid.split(','));
		checkuseridSelect.setValue(dataArray[index].checkuserid.split(','));
	}
}
//将xmselect值放到input中
function setxmSelectValueToInput(dataArray,index,col){
	var valueArray = [];
	var nameArray = [];
	for (var i = 0; i < dataArray.length; i++) {
		valueArray.push(dataArray[i].value);
		nameArray.push(dataArray[i].name);
	}
	parent.$('#'+col+'id'+index).val(valueArray.join(','));
	parent.$('#'+col+index).val(nameArray.join(','));

}
function addoperation(){
	$('#addButton').append(
		'<div class="submit_button w94 bg_red">'
	   +'<span  style="display:inline-block; width:16px; height:16px!important; line-height:14px!important; font-weight:600; font-size:15px; text-align:center; border:1px #fff solid; border-radius:10px; color:#fff!important;">+</span>'
  	   +'新增工作计划</div>'
	);
	 $('#operation').append(
		' <div class="col_box" id="operation">'
	   +'<div><div class="widget-box add_mar_tb7p">'
	   +'<div class="widget-header widget-header-flat widget-header-small add_pad_tb10p add_bor_tbgrey">'
       +'<h5><i class="iconfont">&#xe61e;</i>&nbsp;发送到人</h5><span class="red"></span>'
	   +'<input type="hidden" id="commituserid0" jsonKey="commituserid"/>'
	   +'<input type="text" id="commituser0" index="0" jsonKey="commituser" placeholder="请选择发送到人" readonly="readonly" class="pull-right add_bor_none" style="width: 70%;margin-right: 2%"/>'
	   +'</div></div></div></div>'
	);
	 $('#saveButton').append('<div class="submit_button w94">提交</div> ');
}


